using Commons.Models.Settings.Dtos.Matchers;
using Commons.Models.Settings.Matchers;

namespace Commons.Models.Settings.Mappers.Matchers
{
	public class MatcherMapper : IMapper<MatcherDto, IMatcher<object>>
	{
		public IMatcher<object> Map(MatcherDto config)
		{
			AndMatcher<object> matcher = new AndMatcher<object>();

			RuleMapper ruleMapper = new RuleMapper();
			foreach (RuleDto rule in config.Rules)
			{
				matcher.AddRule(ruleMapper.Map(rule));
			}

			return matcher;
		}
	}
}

